from zhoukao3_0929.po.Base.Base import Base
from selenium.webdriver.common.by import By
import time
class Page(Base):
    # 点击请登录
    denglu_loc=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    def denglu(self):
        self.click(self.denglu_loc)

    # 断言会员登录
    dy1_loc=(By.CLASS_NAME,'reg-new')
    def dy1(self):
        return self.text(self.dy1_loc)

#     输入用户名
    name_loc=(By.NAME,'username')
    def name(self):
        self.send_keys(self.name_loc,'13811033962')

#     输入密码
    password_loc=(By.NAME,'password')
    def password(self):
        self.send_keys(self.password_loc,'123456')

    # 点击登录按钮
    dengluanniu_loc=(By.CSS_SELECTOR,'.finish-btn')
    def dengluanniu(self):
        self.click(self.dengluanniu_loc)

        # 点击首页
        sy_loc = (By.XPATH, '/html/body/div[3]/div[2]/ul/li[1]/a')

        def sy(self):
            self.click(self.sy_loc)

        # 断言欢迎语
        dy1_loc = (By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a')

        def dy1(self):
            return self.text(self.dy1_loc)

    def test_a3mall_login(self):
        try:
            self.goto('http://10.59.9.12:7001/')
            time.sleep(2)
            self.denglu()
            # 强制等待
            time.sleep(2)
            assert "会员登录" ==self.dy1()
            print(self.dy1())
            self.name()
            self.password()
            time.sleep(10)
            self.dengluanniu()
            time.sleep(2)
            time.sleep(2)
            self.sy()
            time.sleep(2)
            assert "欢迎回来，13811033962" == self.dy1()
            print(self.dy1())
        except Exception as e:
            times = time.strftime('%Y%m%d_%H%M%S', time.localtime())
            self.driver.save_screenshot('hj' + times + '.png')